var __extends =
    (this && this.__extends) ||
    (function () {
      var i = function (a, t) {
        return (i =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (i, a) {
              i.__proto__ = a;
            }) ||
          function (i, a) {
            for (var t in a)
              Object.prototype.hasOwnProperty.call(a, t) && (i[t] = a[t]);
          })(a, t);
      };
      return function (a, t) {
        function n() {
          this.constructor = a;
        }
        if ("function" != typeof t && null !== t)
          throw new TypeError(
            "Class extends value " + String(t) + " is not a constructor or null"
          );
        i(a, t),
          (a.prototype =
            null === t
              ? Object.create(t)
              : ((n.prototype = t.prototype), new n()));
      };
    })(),
  FactionHomeView = (function (i) {
    function a() {
      var a = i.call(this) || this;
      return (
        (a.contri_value = ""),
        a.btn_faction_back.on(Laya.Event.CLICK, a, a.onFactionBackDidClick),
        a.btn_fac_yaoqing.on(Laya.Event.CLICK, a, a.onDidClickFactionItem),
        a.btn_fac_shenqing.on(Laya.Event.CLICK, a, a.onDidClickFactionItem),
        a.btn_fac_create.on(Laya.Event.CLICK, a, a.onDidClickFactionItem),
        a.btn_bangpai_gongxian.on(
          Laya.Event.CLICK,
          a,
          a.onDidClickGongXianItem
        ),
        a.btn_bangpaiSetting.on(Laya.Event.CLICK, a, a.onDidClickSettingItem),
        a.btn_bangpaiChengyuan.on(
          Laya.Event.CLICK,
          a,
          a.onDidClickBangPaiManager
        ),
        a.btn_bangpailishi.on(Laya.Event.CLICK, a, a.onDidClickBangPaiManager),
        a.btn_yaoqingjiaru.on(Laya.Event.CLICK, a, a.onDidClickBangPaiManager),
        a.label_fac_notice_edit.on(
          Laya.Event.CLICK,
          a,
          a.onDidClickFacNoticeEdit
        ),
        a.label_fac_bangpaiZhuRen.on(
          Laya.Event.CLICK,
          a,
          a.onBangZhuDetailMessage
        ),
        a.btn_fac_serach.on(
          Laya.Event.CLICK,
          a,
          a.onDidClickFactionSerachAction
        ),
        a.tab_faction_item.on(Laya.Event.CLICK, a, a.onTabDidClickItemAction),
        a.tab_fac_paihang.on(Laya.Event.CLICK, a, a.onTabSeqDidClickItem),
        a.tab_faction2_paihang.on(Laya.Event.CLICK, a, a.onTabSeqDidClickItem),
        (a.list_fac_paihang.vScrollBarSkin = ""),
        (a.list_fac_paihang.selectEnable = !0),
        a.list_fac_paihang.on(Laya.Event.CLICK, a, a.onDidFacPaiHangFn),
        (a.list_fac_paihang.renderHandler = new Handler(a, a.updateBangPaiFn)),
        (a.list_fac_paihang.scrollBar.changeHandler = new Handler(
          a,
          a.onLoadMoreJiaoPaiData
        )),
        (a.list_fac2_paihang.vScrollBarSkin = ""),
        (a.list_fac2_paihang.selectEnable = !0),
        a.list_fac2_paihang.on(Laya.Event.CLICK, a, a.onDidFacPaiHang2Fn),
        (a.list_fac2_paihang.scrollBar.changeHandler = new Handler(
          a,
          a.onLoadFacMoreJiaoPaiData
        )),
        a.btn_bangpai_paili.on(
          Laya.Event.CLICK,
          a,
          a.onBangPaiQuitAndPanLiAction
        ),
        a.btn_bangpai_jiesan.on(Laya.Event.CLICK, a, a.onBangPaiJieSanAction),
        a.btn_fac_linggongzi.on(
          Laya.Event.CLICK,
          a,
          a.onDidClickFacLingGongZiAction
        ),
        WebSocketService.addListener({
          caller: a,
          code: 1126,
          method: a.onLoadMySelfBangpaiDataFn,
        }),
        WebSocketService.addListener({
          caller: a,
          code: 1210,
          method: a.onLoadRankListDataFn,
        }),
        WebSocketService.addListener({
          caller: a,
          code: 1125,
          method: a.onLoadSearchFactionDataFn,
        }),
        WebSocketService.addListener({
          caller: a,
          code: 1223,
          method: a.onLoadLingGongZiDataFn,
        }),
        WebSocketService.addListener({
          caller: a,
          code: 1197,
          method: a.onLoadBangPaiJoinDataFn,
        }),
        WebSocketService.addListener({
          caller: a,
          code: 1226,
          method: a.onLoadBangPaiJieSanDataFn,
        }),
        WebSocketService.addListener({
          caller: a,
          code: 1225,
          method: a.onLoadBangPaiTuiChuDataFn,
        }),
        a
      );
    }
    return (
      __extends(a, i),
      (a.showFactionHomeView = function () {
        return (
          null == this.factionV && (this.factionV = new a()),
          (this.factionV.image_faction2.visible = !0),
          (this.factionV.image_faction1.visible = !1),
          (this.factionV.image_fac_benbang.visible = !0),
          (this.factionV.image_fac_paihang.visible = !1),
          (this.factionV.btn_bangpai_gongxian.visible = !1),
          (this.factionV.btn_fac_yaoqing.visible = !1),
          (this.factionV.btn_yaoqingjiaru.visible = !1),
          (this.factionV.btn_bangpailishi.visible = !1),
          (this.factionV.btn_bangpaiChengyuan.visible = !1),
          (this.factionV.tab_faction_item.selectedIndex = 0),
          (this.factionV.contri_value = ""),
          (this.factionV.btn_fac_linggongzi.visible = !0),
          (this.factionV.bangpaiObj = null),
          WebSocketService.send({ c: 1126 }),
          this.factionV
        );
      }),
      (a.prototype.onTabDidClickItemAction = function (i) {
        "item0" == i.target.name
          ? ((this.image_fac_benbang.visible = !0),
            (this.image_fac_paihang.visible = !1),
            (this.tab_fac_paihang.visible = !1),
            3 == Global.bangpaiMem || 4 == Global.bangpaiMem
              ? ((this.label_fac_notice_edit.visible = !0),
                (this.btn_bangpai_jiesan.visible = !0))
              : ((this.label_fac_notice_edit.visible = !1),
                (this.btn_bangpai_jiesan.visible = !1)),
            (this.btn_fac_linggongzi.visible = !0),
            (this.btn_yaoqingjiaru.visible = !0),
            (this.btn_bangpailishi.visible = !0),
            (this.btn_bangpaiChengyuan.visible = !0),
            (this.btn_bangpai_paili.visible = !0))
          : "item1" == i.target.name
          ? ((this.image_fac_benbang.visible = !1),
            (this.image_fac_paihang.visible = !1),
            (this.btn_fac_linggongzi.visible = !1),
            (this.btn_yaoqingjiaru.visible = !1),
            (this.btn_bangpailishi.visible = !1),
            (this.btn_bangpaiChengyuan.visible = !1),
            (this.btn_bangpai_paili.visible = !1),
            (this.btn_bangpai_jiesan.visible = !1))
          : "item2" == i.target.name
          ? ((this.image_fac_benbang.visible = !1),
            (this.image_fac_paihang.visible = !1),
            (this.btn_fac_linggongzi.visible = !1),
            (this.btn_yaoqingjiaru.visible = !1),
            (this.btn_bangpailishi.visible = !1),
            (this.btn_bangpaiChengyuan.visible = !1),
            (this.btn_bangpai_paili.visible = !1),
            (this.btn_bangpai_jiesan.visible = !1))
          : "item3" == i.target.name &&
            ((this.image_fac_benbang.visible = !1),
            (this.image_fac_paihang.visible = !0),
            (this.tab_fac_paihang.visible = !0),
            WebSocketService.send({ c: 1210, d: { type: 3, pageNum: 0 } }),
            (this.btn_fac_linggongzi.visible = !1),
            (this.btn_yaoqingjiaru.visible = !1),
            (this.btn_bangpailishi.visible = !1),
            (this.btn_bangpaiChengyuan.visible = !1),
            (this.btn_bangpai_paili.visible = !1),
            (this.btn_bangpai_jiesan.visible = !1));
      }),
      (a.prototype.onTabSeqDidClickItem = function (i) {
        var a;
        "item0" == i.target.name
          ? (a = 3)
          : "item1" == i.target.name
          ? (a = 2)
          : "item2" == i.target.name && (a = 1),
          WebSocketService.send({ c: 1210, d: { type: a, pageNum: 0 } });
      }),
      (a.prototype.onLoadMySelfBangpaiDataFn = function (i) {
        if (0 == i.code) {
          (Global.bangpaiID = i.data.id),
            (this.image_faction2.visible = !1),
            (this.image_faction1.visible = !0),
            (this.image_fac_paihang.visible = !1),
            (this.list_fac_paihang.visible = !1),
            (this.tab_fac_paihang.visible = !1),
            (this.image_faction2_paihang.visible = !1),
            (this.tab_faction2_paihang.visible = !1),
            (this.list_fac2_paihang.visible = !1),
            (this.bangpaiObj = i.data),
            3 == i.data.mem || 4 == i.data.mem
              ? (this.label_fac_notice_edit.visible = !0)
              : (this.label_fac_notice_edit.visible = !1),
            (this.btn_bangpai_gongxian.visible = !0),
            (this.btn_yaoqingjiaru.visible = !0),
            (this.label_fac_wodegongxian.text = i.data.present + " "),
            (this.contri_value = i.data.present),
            4 == i.data.mem
              ? ((this.btn_bangpai_paili.label = "转让"),
                (this.btn_bangpai_jiesan.visible = !0))
              : 3 == i.data.mem
              ? ((this.btn_bangpai_paili.label = "退出"),
                (this.btn_bangpai_jiesan.visible = !0))
              : ((this.btn_bangpai_paili.label = "退出"),
                (this.btn_bangpai_jiesan.visible = !1)),
            (Global.bangpaiMem = i.data.mem),
            (Global.bangpaiMinLvl = i.data.minLvl),
            (Global.bangpaiNoticeMsg = i.data.notice);
          for (var a = i.data.kang.split(","), t = 0; t < a.length; t++) {
            var n = a[t];
            0 == t
              ? (Global.bangpaiFirstKang = this.getKeyWithKangValue(n))
              : 1 == t &&
                (Global.bangpaiSecondKang = this.getKeyWithKangValue(n));
          }
          (this.label_fac_bangpaimingzi.text = i.data.name),
            (this.label_fac_bangpaidengji.text = i.data.lvl + "级"),
            (this.label_fac_bangpaiZhuRen.text = i.data.lead),
            (this.label_fac_bangpaiGongGao.text = i.data.notice),
            (this.label_fac_bangpaiShengWang.text = i.data.credit + ""),
            (this.label_fac_bangpaiZiChan.text = i.data.money + "银"),
            (this.label_fac_bangpaiJIaCheng.text = "" + i.data.kang),
            (this.lable_bangpai_shuxing.text =
              "享受主" + i.data.k1 + "%，副" + i.data.k2 + "%帮派加成"),
            (this.btn_fac_yaoqing.visible = !0),
            (this.btn_bangpailishi.visible = !0),
            (this.btn_bangpaiChengyuan.visible = !0),
            1 == i.data.sum
              ? (this.label_no_fac_tip.visible = !0)
              : (this.label_no_fac_tip.visible = !1),
            (this.label_fac_timeDown.visible = !1);
        } else
          1e3 == i.code &&
            ((Global.bangpaiID = null),
            (Global.bangpaiMem = null),
            (Global.bangpaiMinLvl = null),
            (this.image_faction1.visible = !1),
            (this.image_faction2.visible = !0),
            (this.image_fac_paihang.visible = !0),
            (this.image_faction2_paihang.visible = !0),
            (this.btn_fac_yaoqing.visible = !0),
            (this.btn_fac_shenqing.visible = !0),
            (this.btn_fac_create.visible = !0),
            (this.list_fac2_paihang.visible = !1),
            (this.tab_faction2_paihang.visible = !0),
            WebSocketService.send({ c: 1210, d: { type: 1, pageNum: 0 } }),
            (this.label_no_fac_tip.visible = !0),
            (this.label_fac_timeDown.visible = !0));
      }),
      (a.prototype.onLoadRankListDataFn = function (i) {
        if (0 == i.code) {
          if (this.currentPage >= 1) {
            if (0 == i.list.length) return void this.currentPage--;
            for (n = 0; n < i.list.length; n++) {
              var a = i.list[n];
              this.listArr.push(a), (this.dataSource = []);
            }
          } else (this.listArr = i.list), (this.dataSource = []);
          (this.isloading = !1),
            this.listArr.length > 0 &&
              (Global.bangpaiID > 0
                ? (this.list_fac_paihang.visible = !0)
                : (this.list_fac2_paihang.visible = !0));
          for (var t, n = 0; n < this.listArr.length; n++)
            (t = {
              lable_jiaopai_index: { text: n + 1 + "." },
              lable_jiaopai_name: { text: this.listArr[n].name },
              button_jiaopai_join: { label: "加入" },
            }),
              this.dataSource.push(t);
          Global.bangpaiID > 0
            ? (this.list_fac_paihang.dataSource = this.dataSource)
            : (this.list_fac2_paihang.dataSource = this.dataSource);
        }
      }),
      (a.prototype.onLoadMoreJiaoPaiData = function (i) {
        var a = i / this.list_fac_paihang.scrollBar.max,
          t = new Date(),
          n = !1;
        if (
          (t.getTime() - this.spaceTime >= 3e3 && (n = !0),
          1 == a && 0 == this.isloading && n)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            0 == this.tab_fac_paihang.selectedIndex ||
              1 == this.tab_fac_paihang.selectedIndex ||
              this.tab_fac_paihang.selectedIndex,
            void (this.spaceTime = t.getTime())
          );
      }),
      (a.prototype.onLoadFacMoreJiaoPaiData = function (i) {
        var a = i / this.list_fac2_paihang.scrollBar.max,
          t = new Date(),
          n = !1;
        if (
          (t.getTime() - this.spaceTime >= 3e3 && (n = !0),
          1 == a && 0 == this.isloading && n)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            0 == this.tab_faction2_paihang.selectedIndex ||
              1 == this.tab_faction2_paihang.selectedIndex ||
              this.tab_faction2_paihang.selectedIndex,
            void (this.spaceTime = t.getTime())
          );
      }),
      (a.prototype.onFactionBackDidClick = function () {
        this && this.removeSelf();
      }),
      (a.prototype.onDidClickFactionItem = function (i) {
        if ("item_yaoqing" == i.target.name) {
          var a = FactionManagerView.showFacManagerView("yaoqing");
          a.pos(0, 35), Laya.stage.addChild(a);
        } else if ("item_shenqing" == i.target.name) {
          var t = FactionListView.showFacListView("shenqing");
          t.pos(0, 35), Laya.stage.addChild(t);
        } else
          "item_create" == i.target.name && FactionCreateView.openFactionView();
      }),
      (a.prototype.onDidClickGongXianItem = function () {
        var i = this.contri_value;
        FactionContributeDialog.showContributionView(i);
      }),
      (a.prototype.onDidClickSettingItem = function () {
        FactionSettingDialog.showFacSettingView("jiacheng");
      }),
      (a.prototype.onDidClickBangPaiManager = function (i) {
        if ("item_bangpaichengyuan" == i.target.name) {
          (a = FactionManagerView.showFacManagerView("chengyuan")).pos(0, 35),
            Laya.stage.addChild(a);
        } else if ("item_bangpailishi" == i.target.name)
          FactionDetailDialog.openFactionDetailView(this.bangpaiObj, "lishi");
        else if ("item_bangpaiyaoqing" == i.target.name) {
          var a = FactionManagerView.showFacManagerView("yaoqing");
          a.pos(0, 35), Laya.stage.addChild(a);
        }
      }),
      (a.prototype.onDidClickFactionSerachAction = function () {
        this.text_fac_key.text.length <= 0
          ? ToastView.toastView("请先输入帮派名或者帮派ID")
          : WebSocketService.send({
              c: 1125,
              d: { name: this.text_fac_key.text },
            });
      }),
      (a.prototype.onLoadSearchFactionDataFn = function (i) {
        i.code;
      }),
      (a.prototype.onDidFacPaiHangFn = function (i) {
        if ("" != i.target.name)
          if ("button_jiaopai_join" == i.target.name) {
            var a = this.listArr[this.list_fac_paihang.selectedIndex].id;
            WebSocketService.send({ c: 1197, d: { id: a, type: 1 } });
          } else {
            var t = this.listArr[this.list_fac_paihang.selectedIndex];
            FactionDetailDialog.openFactionDetailView(t, "xiangqing");
          }
      }),
      (a.prototype.onDidFacPaiHang2Fn = function (i) {
        if ("" != i.target.name)
          if ("button_jiaopai_join" == i.target.name) {
            var a = this.listArr[this.list_fac2_paihang.selectedIndex].id;
            WebSocketService.send({ c: 1197, d: { id: a, type: 1 } });
          } else {
            var t = this.listArr[this.list_fac2_paihang.selectedIndex];
            FactionDetailDialog.openFactionDetailView(t, "xiangqing");
          }
      }),
      (a.prototype.updateBangPaiFn = function (i, a) {
        if (!(a > this.list_fac_paihang.length)) {
          i.getChildByName("button_jiaopai_join").visible = !1;
        }
      }),
      (a.prototype.onBangPaiQuitAndPanLiAction = function (i) {
        "退出" == i.target.label
          ? NormalDialog.showNormalDialog(
              "您确定要退出该帮派吗？",
              this,
              this.onPanliAndJieSanFac1
            )
          : NormalDialog.showNormalDialog(
              "您确定要转让该帮派吗？",
              this,
              this.onPanliAndJieSanFa2
            );
      }),
      (a.prototype.onPanliAndJieSanFac1 = function () {
        WebSocketService.send({ c: 1225 });
      }),
      (a.prototype.onLoadBangPaiTuiChuDataFn = function (i) {
        Alert.openText(i.msg);
      }),
      (a.prototype.onPanliAndJieSanFa2 = function () {
        AXAlertView.alertOpen("bangpaimanagerToID");
      }),
      (a.prototype.onBangPaiJieSanAction = function () {
        NormalDialog.showNormalDialog(
          "您确定要解散该帮派吗？",
          this,
          this.onJieSanFac
        );
      }),
      (a.prototype.onJieSanFac = function () {
        WebSocketService.send({ c: 1226 });
      }),
      (a.prototype.onDidClickFacNoticeEdit = function () {
        AXAlertView.alertOpen("xiugainotice");
      }),
      (a.prototype.onDidClickFacLingGongZiAction = function () {
        Global.bangpaiID > 0 && WebSocketService.send({ c: 1223 });
      }),
      (a.prototype.onLoadLingGongZiDataFn = function (i) {
        ToastView.toastView(i.msg);
      }),
      (a.prototype.onLoadBangPaiJieSanDataFn = function (i) {
        ToastView.toastView(i.msg);
      }),
      (a.prototype.onLoadBangPaiJoinDataFn = function (i) {
        ToastView.toastView(i.msg);
      }),
      (a.prototype.onBangZhuDetailMessage = function (i) {}),
      (a.prototype.getKeyWithKangValue = function (i) {
        var a = "";
        return (
          -1 != i.indexOf("物理")
            ? (a = "物")
            : -1 != i.indexOf("击")
            ? (a = "击")
            : -1 != i.indexOf("封")
            ? (a = "封")
            : -1 != i.indexOf("围")
            ? (a = "围")
            : -1 != i.indexOf("乱")
            ? (a = "乱")
            : -1 != i.indexOf("风")
            ? (a = "风")
            : -1 != i.indexOf("火")
            ? (a = "火")
            : -1 != i.indexOf("毒")
            ? (a = "毒")
            : -1 != i.indexOf("雷") && (a = "雷"),
          a
        );
      }),
      a
    );
  })(ui.FactionController.FactionHomeViewUI);
